<?php
/**
 * 周舟 hzboye010@163.com
 * addby sublime snippets
 * Code Test 验证码测试类
 */

namespace app\test\controller;

use app\utils\BoyeService;
use app\test\controller\Ava;

class Message extends Ava{

    //发送系统消息
    public function system(){
        if(IS_AJAX){
            $uid  = I('post.uid','');
            $msg  = I('post.msg','');
            $data = [
                'uid'     =>$uid,
                'msg'     =>$msg,
                'api_ver' =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Message_system',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_system');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['uid',143,LL('need-mark to user ID if-0-broadcast')],
                ['msg','hi',LL('need-mark message-content')],
            ]);
            echo $this->display('ava/test');
        }
    }
    //已读信息 修改status
    public function read(){
        if(IS_AJAX){
            $uid    = I('post.uid','');
            $id     = I('post.id','');
            $data = [
                'uid'     =>$uid,
                'id'      =>$id,
                'api_ver' =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Message_read',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_read');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['uid',42,LL('need-mark user ID')],
                ['id',1,LL('need-mark call user ID')],
            ]);
            echo $this->display('ava/test');
        }
    }
    //删除信息 修改status
    public function delete(){
        if(IS_AJAX){
            $data = [
                'uid'       =>I('post.uid',''),
                'ids'       =>I('post.ids',''),
                'api_ver'   =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Message_delete',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_delete');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['uid',42,LL('need-mark user ID')],
                ['ids',1,LL('need-mark msg-ids')],
            ]);
            echo $this->display('ava/test');
        }
    }
    //发送私信
    public function call(){
        if(IS_AJAX){
            $data = [
                'uid'       =>I('post.uid'),
                'to_uid'    =>I('post.to_uid'),
                'message'   =>I('post.message'),
                'api_ver'   =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Message_call',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_call');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['uid',42,LL('need-mark user ID')],
                ['to_uid',50,LL('need-mark call user ID')],
                ['message','',L('message')]
            ]);
            echo $this->display('ava/test');
        }
    }
    //发送短信息
    public function sendSms(){
        if(IS_AJAX){
            $mobile    = I('post.mobile','');
            $code_type = I('post.code_type','');

            $data = [
                'mobile'    =>$mobile,
                'code_type' =>$code_type,
                'api_ver'   =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Message_send_sms',
            ];
            $service = new BoyeService();
            $result  = $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_send_sms');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['mobile','17195862186',LL('need-mark phone-number')],
                ['code_type','1',LL('need-mark code-type')],
            ]);
            echo $this->display('ava/test');
        }
    }

    public function checkCode(){
        if(IS_AJAX){
            $mobile    = I('post.mobile','');
            $code      = I('post.code','');
            $code_type = I('post.code_type','');

            $data = [
                'mobile'    =>$mobile,
                'code'      =>$code,
                'code_type' =>$code_type,
                'api_ver'   =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Message_checkCode',
            ];

            $service = new BoyeService();
            $result= $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_checkCode');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['mobile','17195862186',LL('need-mark phone-number')],
                ['code_type','1',LL('need-mark code-type')],
                ['code','1',LL('need-mark validate-code')],
            ]);
            echo $this->display('ava/test');
        }
    }
    // 私信消息分页查询
    public function queryCall(){
        if(IS_AJAX){
            $data = [
                'uid'        =>I('post.uid',''),
                'start_time' =>I('post.start_time',''),
                'page_no'    =>I('post.page_no',1),
                'page_size'  =>I('post.page_size',10),
                'api_ver'    =>$this->api_ver,
                'notify_id'  =>$this->notify_id,
                'alg'        =>$this->alg,
                'type'       =>'BY_Message_queryCall',
            ];

            $service = new BoyeService();
            $result= $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_queryCall');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['uid',25,LL('need-mark user ID')],
                ['start_time','',LL('start time')],
                ['page_no',1,L('page')],
                ['page_size',10,LL('page size')]
            ]);
            echo $this->display('ava/test');
        }
    }
    // 2人间私信删除
    public function deleteCall(){
        if(IS_AJAX){
            $data = [
                'curr_uid'  =>I('post.curr_uid',''),
                'rela_uid'  =>I('post.rela_uid',''),
                'api_ver'   =>$this->api_ver,
                'notify_id' =>$this->notify_id,
                'alg'       =>$this->alg,
                'type'      =>'BY_Message_deleteCall',
            ];

            $service = new BoyeService();
            $result= $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_deleteCall');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['curr_uid',50,LL('need-mark current user ID')],
                ['rela_uid',42,LL('need-mark relation user ID')],
            ]);
            echo $this->display('ava/test');
        }
    }
    // 私信详情分页查询
    public function detailCall(){
        if(IS_AJAX){
            $data = [
                'curr_uid'   =>I('post.curr_uid',''),
                'rela_uid'   =>I('post.rela_uid',''),
                'start_time' =>I('post.start_time',''),
                'page_no'    =>I('post.page_no',1),
                'page_size'  =>I('post.page_size',10),
                'api_ver'    =>$this->api_ver,
                'notify_id'  =>$this->notify_id,
                'alg'        =>$this->alg,
                'type'       =>'BY_Message_detailCall',
            ];

            $service = new BoyeService();
            $result= $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_detailCall');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['curr_uid',50,LL('need-mark current user ID')],
                ['rela_uid',42,LL('need-mark relation user ID')],
                ['start_time','',LL('start time')],
                ['page_no',1,L('page')],
                ['page_size',10,LL('page size')]
            ]);
            echo $this->display('ava/test');
        }
    }
    // 消息分页查询
    public function query(){
        if(IS_AJAX){
            $data = [
                'uid'        =>I('post.uid',''),
                'msg_type'   =>I('post.msg_type',''),
                'start_time' =>I('post.start_time',''),
                'page_no'    =>I('post.page_no',1),
                'page_size'  =>I('post.page_size',10),
                'api_ver'    =>$this->api_ver,
                'notify_id'  =>$this->notify_id,
                'alg'        =>$this->alg,
                'type'       =>'BY_Message_query',
            ];

            $service = new BoyeService();
            $result= $service->callRemote("",$data,true);
            echo $this->parseResult($result);
        }else{
            $this->assign('type','BY_Message_query');
            $this->assign('field',[
                ['api_ver','100',LL('need-mark api version')],
                ['uid',25,LL('need-mark user ID')],
                ['msg_type',5,LL('need-mark msg-type')],
                ['start_time','',LL('start time')],
                ['page_no',1,L('page')],
                ['page_size',10,LL('page size')]
            ]);
            echo $this->display('ava/test');
        }
    }

    public function __construct(){
        parent::__construct();
    }
}